<template>
  <div style='height: 100%'>
    <el-breadcrumb separator-class='el-icon-arrow-right'>
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>健康信息管理</el-breadcrumb-item>
    </el-breadcrumb>
    <el-card style='height: 95%'>
      <el-row :gutter='20'>
        <el-col :span='5'>
          <el-input placeholder='请输入内容' v-model='queryInfo.query'
                    clearable @clear='getUserList'>
            <el-button slot='append' icon='el-icon-search' @click='getUserList'></el-button>
          </el-input>
        </el-col>
        <el-col :span='4'>
        </el-col>
      </el-row>

      <el-table :data='dataList' border stripe height='600px'>
        <el-table-column type='index' label='编号' />
        <el-table-column label='日期' prop='time' />
        <el-table-column label='姓名' prop='student.studentName' />
        <el-table-column label='学号' prop='student.studentID' />
        <el-table-column label='年级' prop='student.grade' />
        <el-table-column label='班级' prop='student.className' />
        <el-table-column label='宿舍' prop='student.addr' />
        <el-table-column label='体温' prop='bodyTemperature' />
        <el-table-column label="是否咳嗽" prop="cough">
          <template #default="scope">
            <el-tag v-if="scope.row.cough === 0" :type="'success'" effect="dark">否</el-tag>
            <el-tag v-else :type="'warning'" effect="dark">是</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="是否生病" prop="sick">
          <template #default="scope">
            <el-tag v-if="scope.row.sick === 0" :type="'success'" effect="dark">否</el-tag>
            <el-tag v-else :type="'warning'" effect="dark">是</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="是否外出" prop="travel">
          <template #default="scope">
            <el-tag v-if="scope.row.travel === 0" :type="'success'" effect="dark">否</el-tag>
            <el-tag v-else :type="'warning'" effect="dark">是</el-tag>
          </template>
        </el-table-column>
      </el-table>
      <!--分页区域-->
      <el-pagination
        @size-change='handleSizeChange'
        @current-change='handleCurrentChange'
        :current-page='queryInfo.pageNum'
        :page-sizes='[10, 20, 50, 100]'
        :page-size='queryInfo.pageSize'
        layout='sizes, prev, pager, next, jumper'
        :total='this.total'
        style='float: right'>
      </el-pagination>
    </el-card>
  </div>
</template>

<script>
export default {
  name: 'bodyTemperature',
  data() {
    return {
      queryInfo: {
        query: '',
        pageNum: 1,
        pageSize: 10
      },
      dataList: [],
      total: 0,
      dialogFormVisible: false
    }
  },
  created() {
    this.getUserList()
  },
  methods: {
    async getUserList() {
      const { data: res } = await this.$http.get('/api/bodytemperature/getPage', { params: this.queryInfo })
      if (res.code !== 0) {
        return this.$message.error('获取用户失败')
      }
      this.dataList = res.data.records
      this.total = res.data.total
    },
    // 监听pagesize改变事件
    handleSizeChange(newSize) {
      this.queryInfo.pagesize = newSize
      this.getUserList()
    },
    // 页码值改变事件
    handleCurrentChange(newNum) {
      this.queryInfo.pagenum = newNum
      this.getUserList()
    },
    abc: (val) => {
      this.dialogFormVisible = val
      alert(this.dialogFormVisible)
    }
  }
}
</script>

<style scoped>

</style>
